<?php
defined('_JEXEC') or die('Restricted access');
	$app = JFactory::getApplication();
	$templatepath = JURI::base() . 'templates/' . $app->getTemplate();
?>
<form class="top-footer-l" action="<?php echo JRoute::_('index.php'); ?>" method="get" id="f-newsletter" name="f-newsletter">
	<label><img src="<?php echo $templatepath; ?>/img/label-newsletter.png" width="279" height="21" alt=""></label>
	<input name="email" id="email" type="text" value="Indtast din e-mail">
	<a id="bnt-send" class="bnt" href="#" onclick="jQuery('#f-newsletter').submit();">Tilmeld</a>
		<input type="hidden" name="ctrl" value="mailchimp" />
		<input type="hidden" name="task" value="add" />
		<input type="hidden" name="option" value="com_acymailing" />
		<input type="hidden" name="api_key" value="24df83a72e0f1fcb0d88957ab3d474dc-us6" />
		<input type="hidden" name="list_id" value="06e7b6dc95" />
		<?php echo JHtml::_( 'form.token' ); ?>
</form>

<?php								   
$input_name = JText::_( 'Indtast din Navn' );
$input_phone = JText::_( 'Indtast din Telefon' );
$input_email = JText::_( 'Indtast din E-mail' );
$input_username = JText::_( 'Indtast din Brugernavn' );
$input_password = JText::_( 'Indtast din Kordeord' );
$input_password1 = JText::_( 'Indtast din Bekræft Kordeord' );
$input_message = JText::_( 'Indtast din Besked' );
	
?>						
 <script type="text/javascript">				   
jQuery(document).ready(function(jQuery) {
	jQuery.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		return /^\d{4}$/.test(value); 
	   }, '');
	jQuery.validator.addMethod("notEqual", function(value, element, param) {
			return this.optional(element) || value !== param;
	});
		//jQuery("#postcode").mask("9999",{placeholder:""});  
		jQuery("#f-newsletter").validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
				//$('#alert').html(validator['errorList'][0]['message']);
				jQuery('#alert').html(validator['errorList'][0]['message']);
				jQuery('#backoverlay').show();
				jQuery('#show_popup').show();
				jQuery('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				
			  } else {
			  }
			},
			rules: {
				
				email:{
					required: true,
					email: true,
				},	
				
			},
			messages: {
				email: "<?php echo $input_email; ?>",
			}
		});
		close_popup=function(){		
			var fel=jQuery('#f_focus').html();
			jQuery('#backoverlay').hide();
			jQuery('#show_popup').hide();
			jQuery('#' + fel ).focus();		
	  };
	  
	  
	});
</script>
<?php return; ?>
<?php
//INTRO
	$introText = $params->get('introtext'); if(!empty($introText)) echo '<p>'.$introText.'</p>';
	$style = array();
	if($params->get('effect','normal') == 'mootools-slide'){
		if(!empty($mootoolsIntro)) echo '<p class="acymailing_mootoolsintro">'.$mootoolsIntro.'</p>'; ?>
		<div class="acymailing_mootoolsbutton" id="acymailing_toggle_<?php echo $formName; ?>" >
			<p><a class="acymailing_togglemodule" id="acymailing_togglemodule_<?php echo $formName; ?>" href="#subscribe"><?php echo $mootoolsButton ?></a></p>
	<?php
	}
	if($params->get('textalign','none') != 'none') $style[] .= 'text-align:'.$params->get('textalign');
	$styleString = empty($style) ? '' : 'style="'.implode(';',$style).'"';
	?>
	<form class="top-footer-l" id="<?php echo $formName; ?>" action="<?php echo JRoute::_('index.php'); ?>" onsubmit="return submitacymailingform('optin','<?php echo $formName;?>')" method="post" name="<?php echo $formName ?>" <?php if(!empty($fieldsClass->formoption)) echo $fieldsClass->formoption; ?> >				
<?php
	if(!empty($fieldsClass->excludeValue)){
		$js = "\n"."<!--"."\n"."acymailing['excludeValues".$formName."'] = Array();";
		foreach($fieldsClass->excludeValue as $namekey => $value){
			$js .= "\n"."acymailing['excludeValues".$formName."']['".$namekey."'] = '".$value."';";
		}
		$js .= "\n"."//-->";
		$doc =& JFactory::getDocument();
			if($params->get('includejs','header') == 'header'){
				$doc->addScriptDeclaration( $js );
			}else{
				echo "<script type=\"text/javascript\">
						$js
						</script>";
			}
	}
	?>
	<label><img src="<?php echo $templatepath; ?>/img/label-newsletter.png" width="279" height="21" alt=""></label>
	<input value="Indtast din email-adresse" id="user_email_<?php echo $formName; ?>" <?php if(!empty($identifiedUser->userid)) echo 'disabled="disabled" ';  if(!$displayOutside){ ?> onfocus="if(this.value == 'Indtast din email-adresse') this.value = '';" onblur="if(this.value=='') this.value='Indtast din email-adresse';"<?php } ?> class="inputbox" type="text" name="user[email]" size="<?php echo $params->get('fieldsize',15)?>" value="<?php if(!empty($identifiedUser->userid)) echo $identifiedUser->email; elseif(!$displayOutside) echo $emailCaption; ?>" />
	<?php if($params->get('showsubscribe',true)){?>
	<a class="bnt" id="form-subscribe" href="javascript:" onclick="document.getElementById('sbtn').click()"><?php echo $params->get('subscribetext',JText::_('SUBSCRIBECAPTION'))?></a><input style="display:none" class="button subbutton" id="sbtn" type="submit" value="<?php $subtext = $params->get('subscribetextreg',JText::_('SUBSCRIBECAPTION')); if(empty($identifiedUser->userid) OR empty($subtext)){ $subtext = $params->get('subscribetext',JText::_('SUBSCRIBECAPTION')); } echo $subtext;  ?>" name="Submit" onclick="try{ return submitacymailingform('optin','<?php echo $formName;?>'); }catch(err){alert('The form could not be submitted '+err);return false;}"/>
	<?php }//SUB-BUTTON
	if($params->get('showunsubscribe',false) AND (!$params->get('showsubscribe',true) OR empty($identifiedUser->userid) OR !empty($countUnsub)) ){?>
	<a class="gradient" id="form-unsubscribe" href="javascript:" onclick="document.getElementById('ubtn').click()"><?php echo $params->get('unsubscribetext',JText::_('UNSUBSCRIBECAPTION'))?></a><input  style="display:none" class="button unsubbutton" id="ubtn" type="button" value="<?php echo $params->get('unsubscribetext',JText::_('UNSUBSCRIBECAPTION')); ?>" name="Submit" onclick="return submitacymailingform('optout','<?php echo $formName;?>')"/>
	<?php }//UNSUB-BUTTON ?>
					
<?php //END FORM?>
	<?php $postText = $params->get('finaltext'); if(!empty($postText)) echo '<span class="acymailing_finaltext">'.$postText.'</span>';
	$ajax = ($params->get('redirectmode') == '3') ? 1 : 0;?>
	<input type="hidden" name="ajax" value="<?php echo $ajax; ?>"/>
	<input type="hidden" name="ctrl" value="sub"/>
	<input type="hidden" name="task" value="notask"/>
	<input type="hidden" name="redirect" value="<?php echo urlencode($redirectUrl); ?>"/>
	<input type="hidden" name="redirectunsub" value="<?php echo urlencode($redirectUrlUnsub); ?>"/>
	<input type="hidden" name="option" value="<?php echo ACYMAILING_COMPONENT ?>"/>
	<?php if(!empty($identifiedUser->userid)){ ?><input type="hidden" name="visiblelists" value="<?php echo $visibleLists;?>"/><?php } ?>
	<input type="hidden" name="hiddenlists" value="<?php echo $hiddenLists;?>"/>
	<input type="hidden" name="acyformname" value="<?php echo $formName; ?>" />
	<?php if(JRequest::getCmd('tmpl') == 'component'){ ?>
		<input type="hidden" name="tmpl" value="component" />
		<?php if($params->get('effect','normal') == 'mootools-box' AND !empty($redirectUrl)){ ?>
			<input type="hidden" name="closepop" value="1" />
		<?php } } ?>
	<?php $myItemId = $config->get('itemid',0); if(empty($myItemId)){ global $Itemid; $myItemId = $Itemid;} if(!empty($myItemId)){ ?><input type="hidden" name="Itemid" value="<?php echo $myItemId;?>"/><?php } ?>
</form>
